package com.why.day05_work3;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;


import com.why.day05_work3.base.BaseActivity;
import com.why.day05_work3.bean.NaviBean;
import com.why.day05_work3.presenter.MainPresenter;
import com.why.day05_work3.ui.adapter.RlvAdapter;
import com.why.day05_work3.view.MainView;

import java.util.ArrayList;



public class MainActivity extends BaseActivity<MainPresenter>
        implements MainView {


    private RecyclerView mRlv;
    private RlvAdapter mAdapter;

    //就近原则
    @Override
    protected int getLayout() {
        return R.layout.activity_main;
    }

    @Override
    protected MainPresenter initPresenter() {
        return new MainPresenter();
    }

    @Override
    protected void initData() {
        mPresenter.getData();
    }

    @Override
    protected void initView() {
        mRlv = (RecyclerView) findViewById(R.id.rlv);
        ArrayList<NaviBean.DataBean> list = new ArrayList<>();

        mRlv.setLayoutManager(new LinearLayoutManager(this));

        mAdapter = new RlvAdapter(this,list);

        mRlv.setAdapter(mAdapter);
    }


    @Override
    public void setData(NaviBean bean) {
        Log.d("tag", "setData: "+bean.toString());
        mAdapter.addData(bean.getData());
    }
}
